package org.example.musicserver.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.example.musicserver.common.Result;
import org.example.musicserver.entity.Information;
import org.example.musicserver.service.InformationService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/information")
@Tag(name = "资讯相关接口")
public class InformationController {

    @Resource
    private InformationService informationService;

    @PostMapping("/add")
    @Operation(summary = "添加资讯")
    public Result addInformation(@RequestBody Information Information) {
        return informationService.addInformation(Information);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除资讯")
    public Result deleteInformation(@RequestParam Integer InformationId) {
        return informationService.deleteInformation(InformationId);
    }

    @PostMapping("/update")
    @Operation(summary = "修改资讯")
    public Result updateInformation(@RequestBody Information Information) {
        return informationService.updateInformation(Information);
    }

    @GetMapping("/select")
    @Operation(summary = "查询资讯")
    public Result selectInformation(@RequestParam(required = false) String query){
        return informationService.selectInformation(query);
    }

    @GetMapping("/detail")
    @Operation(summary = "资讯详情")
    public Result detailInformation(@RequestParam Integer id){
        return informationService.detail(id);
    }
}
